home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
BARNET
/
COMPILER
/
SATHER
/
!Sather
/
Library
/
Base
/
test
/
sa
/
aref
next >
Wrap
Text File
|
1996-04-09
|
3KB
|
82 lines
---------------------------> Sather 1.1 source file <--------------------------
-- test_aref.sa:
-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>
-- Copyright (C) 1995, International Computer Science Institute
-- $Id: aref_test.sa,v 1.2 1996/04/09 10:04:11 borisv Exp $
--
-- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
-- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
-- LICENSE contained in the file: Sather/Doc/License of the
-- Sather distribution. The license is also available from ICSI,
-- 1947 Center St., Suite 600, Berkeley CA 94704, USA.
-------------------------------------------------------------------
class TEST_AREF is
include TEST;
main is
class_name("AREF{INT}");
a ::= #AREF{INT}(5);
a[0] := 0; a[1] := 1; a[2] := 2; a[3]:=3; a[4]:=4;
test("aset and aget",a[2].str,"2");
res::=""; loop res := res+" "+a.aelt!; end;
test("aelt!",res," 0 1 2 3 4");
res:=""; loop res := res+" "+a.aelt!(1); end;
test("aelt!(beg)",res," 1 2 3 4");
res:=""; loop res := res+" "+a.aelt!(1,2); end;
test("aelt!(1,2)",res," 1 2");
res:=""; loop res := res+" "+a.aelt!(1,2,2); end;
test("aelt!(1,2,2)",res," 1 3");
b ::=#AREF{INT}(a.asize);
b.acopy(a);
res:=""; loop res := res+" "+b.aelt!; end;
test("acopy",res," 0 1 2 3 4");
c ::= #AREF{INT}(3);
c.acopy(a);
res:=""; loop res := res+" "+c.aelt!; end;
test("acopy",res," 0 1 2");
loop b.aset!(1); end;
res:=""; loop res := res+" "+b.aelt!; end;
test("aset",res," 1 1 1 1 1");
b.acopy(a);
loop b.aset!(3,1); end;
res:=""; loop res := res+" "+b.aelt!; end;
test("aset(3,1)",res," 0 1 2 1 1");
b.acopy(a);
loop b.aset!(2,2,7); end;
res:=""; loop res := res+" "+b.aelt!; end;
test("aset(2,2,7)",res," 0 1 7 7 4");
b.acopy(a);
loop b.aset!(1,2,2,9); end;
res:=""; loop res := res+" "+b.aelt!; end;
test("aset(1,2,2,9)",res," 0 9 2 9 4");
b.acopy(1,a);
res:=""; loop res := res+" "+b.aelt!; end;
test("acopy(1)",res," 0 0 1 2 3");
b.aclear;
res:=""; loop res := res+" "+b.aelt!; end;
test("acopy(1)",res," 0 0 0 0 0");
b.acopy(2,2,a);
res:=""; loop res := res+" "+b.aelt!; end;
test("acopy(2,2)",res," 0 0 0 1 0");
b.acopy(2,2,2,a);
res:=""; loop res := res+" "+b.aelt!; end;
test("acopy(2,2)",res," 0 0 2 3 0");
finish;
end;
end; -- class TEST_AREF
-------------------------------------------------------------------